﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DVK.SP2007
{
    /// <summary>
    /// Is a DTO class for holding Persons metadata. 
    /// Normally metadata is from User Information List or Profile Service.
    /// 
    /// This is mapped to setting "DvkPersonMetadataFieldsMapping" in json format.
    /// </summary>
    public class PersonMetadata
    {
        /// <summary>
        /// Gets or sets the person code.
        /// </summary>
        /// <value>The person code.</value>
        public string PersonCode { get; set; }
        /// <summary>
        /// Gets or sets the first name.
        /// </summary>
        /// <value>The first name.</value>
        public string FirstName { get; set; }
        /// <summary>
        /// Gets or sets the surname.
        /// </summary>
        /// <value>The surname.</value>
        public string SurName { get; set; }
        /// <summary>
        /// Gets or sets the name of the department.
        /// </summary>
        /// <value>The name of the department.</value>
        public string DepartmentName { get; set; }
        /// <summary>
        /// Gets or sets the job title.
        /// </summary>
        /// <value>The job title.</value>
        public string JobTitle { get; set; }
        /// <summary>
        /// Gets or sets the email.
        /// </summary>
        /// <value>The email.</value>
        public string Email { get; set; }
        /// <summary>
        /// Gets or sets the telephone.
        /// </summary>
        /// <value>The telephone.</value>
        public string Telephone { get; set; }

        public string OrganisationName { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="PersonMetadata"/> class.
        /// 
        /// Used mainly for json.
        /// </summary>
        public PersonMetadata()
        {
        }

        /// <summary>
        /// Gets the fullname (Firstname Lastname).
        /// </summary>
        /// <value>The fullname of the person.</value>
        public string PersonName
        {
            get {
                return 
                    (string.IsNullOrEmpty(FirstName) ? "" : FirstName) + 
                    " " +
                    (string.IsNullOrEmpty(SurName) ? "" : SurName);
            }
        }
    }
}
